package com.wugui.datax.admin.tool.generate.query;

import com.wugui.datax.admin.tool.generate.sql.GenerateSqlInterface;
import com.wugui.datax.admin.tool.generate.util.QueryBody;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * RDBMS数据库查询
 */
public class GenerateBaseQueryTool implements GenerateQueryToolInterface {
    protected static final Logger logger = LoggerFactory.getLogger(GenerateBaseQueryTool.class);


    GenerateSqlInterface ds;

    public GenerateBaseQueryTool(GenerateSqlInterface ds) {
        this.ds = ds;
    }

    /**
     * 主查询接口
     *
     * @param qb
     * @return
     */
    @Override
    public Object query(QueryBody qb) {
        String querySql = buildSql(qb);


        return null;
    }

    public String buildSql(QueryBody qb) {
        StringBuilder sql = new StringBuilder("SELECT ");
        sql.append(ds.exampleSelectColumns(qb));
        sql.append(ds.fromTable(qb));
        sql.append(ds.exampleWhereClause(qb));
        sql.append(ds.exampleOrderBy(qb));
        return sql.toString();
    }

}
